//
//  VideoChatUserViewSmall.m
//  UniversalApp
//
//  Created by 志刚杨 on 2018/3/26.
//  Copyright © 2018年 voidcat. All rights reserved.
//

#import "VideoChatUserViewSmall.h"

@implementation VideoChatUserViewSmall

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    
    ViewBorderRadius(self, 1, 1, RGB(199, 199, 197));
    
    self.layer.shadowColor = [UIColor colorWithRed:110/255.0 green:109/255.0 blue:124/255.0 alpha:1].CGColor;//阴影颜色
    self.layer.shadowOffset = CGSizeMake(0, 3);//偏移距离
    self.layer.shadowOpacity = 0.8;//不透明度
    self.layer.shadowRadius = 12;//半径
    
    
    //添加手势
    UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGestureRecognizer:)];
    [self addGestureRecognizer:tapGesture];
    
    
    return self;
}

- (void)handleTapGestureRecognizer:(UITapGestureRecognizer *)gestureRecognizer {
    if(self.UserVideoChatClick)
    {
        self.UserVideoChatClick(_randVideo);
    }
}

-(void)createUI
{
    _headerImage = [[UIImageView alloc] init];
    _headerImage.contentMode = UIViewContentModeScaleAspectFill;
    [self addSubview:_headerImage];
    
    [_headerImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    
    _nickname = [[UILabel alloc] init];
    _nickname.text = @"...";
    _nickname.font = DEFAULT_FONT(12);
    _nickname.frame = CGRectMake(2, 2, 100, 20);
    _nickname.textColor = [UIColor whiteColor];
    [self addSubview:_nickname];
    
}

-(void)setRandVideo:(RandList *)randVideo
{
    _randVideo = randVideo;
    _nickname.text = _randVideo.user_nickname;
    [_headerImage sd_setImageWithURL:safeurl(_randVideo.avatar) placeholderImage:emptyimage];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
